﻿package mortal.game.scene3D.player.entity
{
    import Framework.Util.*;
    import Message.BroadCast.*;
    import Message.Client.*;
    import Message.DB.Tables.*;
    import Message.Public.*;
    import __AS3__.vec.*;
    import baseEngine.modifiers.*;
    import baseEngine.system.*;
    import com.gengine.utils.*;
    import com.gengine.utils.pools.*;
    import com.greensock.*;
    import com.mui.utils.*;
    import extend.language.*;
    import flash.geom.*;
    import flash.utils.*;
    import frEngine.effectEditTool.temple.*;
    import frEngine.event.*;
    import frEngine.pools.*;
    import mortal.component.gconst.*;
    import mortal.game.*;
    import mortal.game.manager.*;
    import mortal.game.resource.*;
    import mortal.game.resource.info.*;
    import mortal.game.resource.tableConfig.*;
    import mortal.game.rules.*;
    import mortal.game.scene3D.display3d.blood.*;
    import mortal.game.scene3D.events.*;
    import mortal.game.scene3D.fight.*;
    import mortal.game.scene3D.layer3D.utils.*;
    import mortal.game.scene3D.map3D.*;
    import mortal.game.scene3D.map3D.AstarAnyDirection.data.*;
    import mortal.game.scene3D.map3D.util.*;
    import mortal.game.scene3D.model.data.*;
    import mortal.game.scene3D.model.player.*;
    import mortal.game.scene3D.model.player.weapon.*;
    import mortal.game.scene3D.model.pools.*;
    import mortal.game.scene3D.player.type.*;
    import mortal.game.utils.*;
    import mortal.game.view.common.*;
    import mortal.game.view.systemSetting.*;

    public class MonsterPlayer extends MovePlayer
    {
        public var bossInfo:BossInfo;
        public var isLifeBoss:Boolean = false;
        public var isRobot:Boolean = false;
        protected var lifeArray:Array;
        protected var actionArray:Array;
        private var _hangPlayer:ActionPlayer;
        protected var _effectPlayerArray:Vector.<EffectPlayer>;
        protected var _selectable:Boolean = false;
        protected var _isEnemyTrap:Boolean = false;
        protected var _deathTween:TweenLite;
        private var _nextTalkTime:int;
        private var _followTalkTime:int;
        private var _showTime:int = 0;
        protected var _hairPlayer:ActionPlayer;
        protected var _weaponPlayer:WeaponPlayer;
        private var _judgeDeathTime:int = 0;
        private var _isJudgeDeath:Boolean = false;
        protected var _isNoticeRemove:Boolean = false;
        protected var _collectProBar:BaseProgressBar;

        public function MonsterPlayer()
        {
            this.lifeArray = new Array();
            this.actionArray = new Array();
            this._effectPlayerArray = new Vector.<EffectPlayer>;
            overPriority = Game2DOverPriority.Monster;
            return;
        }// end function

        public function get tboss() : BossInfo
        {
            return this.bossInfo;
        }// end function

        override public function get type() : int
        {
            return EEntityType._EEntityTypeBoss;
        }// end function

        override public function hoverTest(param1:Number, param2:Number, param3:Number, param4:Number) : Boolean
        {
            if (!this._selectable)
            {
                return false;
            }
            return super.hoverTest(param1, param2, param3, param4);
        }// end function

        override public function updateInfo(param1:Object, param2:Boolean = true) : void
        {
            var _loc_3:String = null;
            super.updateInfo(param1, param2);
            if (this.bossInfo)
            {
                if (entityInfo.entityInfo.isInit)
                {
                    if (!this.bossInfo.aiBehaviorLifeAction)
                    {
                        _loc_3 = GlobalStaticResUrl.MonsterBorn;
                        if (this.bossInfo.birthEffect)
                        {
                            _loc_3 = this.bossInfo.birthEffect;
                            entityInfo.isHide = true;
                            this._showTime = setTimeout(this.showModel, 1000);
                            _bodyPlayer.visible = false;
                            _bodyPlayer.openShadow = false;
                            this.updateHeadContainer();
                        }
                        this.playBirthEffect(_loc_3);
                    }
                }
                this.topTalk(this.bossInfo.talkBirthId);
            }
            return;
        }// end function

        protected function showModel() : void
        {
            entityInfo.isHide = false;
            _bodyPlayer.visible = true;
            _bodyPlayer.openShadow = true;
            this.updateHeadContainer();
            return;
        }// end function

        override public function walking(param1:Array) : void
        {
            var _loc_2:AstarTurnPoint = null;
            if (param1.length)
            {
                _loc_2 = param1[(param1.length - 1)];
                setRealPoint(_loc_2._x, _loc_2._y);
            }
            super.walking(param1);
            return;
        }// end function

        override public function diversion(param1:Array) : void
        {
            var _loc_2:AstarTurnPoint = null;
            if (param1.length)
            {
                _loc_2 = param1[(param1.length - 1)];
                setRealPoint(_loc_2._x, _loc_2._y);
            }
            super.diversion(param1);
            return;
        }// end function

        override public function updateVisible() : void
        {
            this.addToStage(Game.scene.playerLayer);
            return;
        }// end function

        override public function updateStatus(param1:int, param2:Boolean = true) : void
        {
            super.updateStatus(param1, param2);
            if (entityInfo.isInHidden)
            {
                this.setAction(ActionType.Speical, ActionName.StandHidden);
                bodyPlayer.material.materialParams.isOpenHerizionKil = true;
                bodyPlayer.openShadow = false;
            }
            this.updateSelectable();
            return;
        }// end function

        override protected function updateSpecialStatus() : void
        {
            if (entityInfo.isInBorn)
            {
                this.setAction(ActionType.Speical, ActionName.StandStart);
                bodyPlayer.material.materialParams.isOpenHerizionKil = true;
                bodyPlayer.openShadow = true;
            }
            else if (entityInfo.isInHidden)
            {
                this.setAction(ActionType.Speical, ActionName.StandHidden);
                bodyPlayer.material.materialParams.isOpenHerizionKil = true;
                bodyPlayer.openShadow = false;
                onMouseOut();
            }
            else
            {
                bodyPlayer.material.materialParams.isOpenHerizionKil = false;
                bodyPlayer.openShadow = true;
                FrEventDispatcher.instance.proxyDispatchEvent(this, PlayerEvent.ENTITY_SPECIALBONECOMPLETE, [this]);
            }
            this.updateSelectable();
            this.updateHeadContainer();
            return;
        }// end function

        protected function updateSelectable() : void
        {
            if (entityInfo && (entityInfo.isInHidden || entityInfo.entityInfo.life <= 0))
            {
                this._selectable = false;
            }
            else if (this.bossInfo)
            {
                if (this.bossInfo.attackMode == EAttackMode._EAttackModeAttackOnly)
                {
                    this._selectable = true;
                }
                else
                {
                    this._selectable = BossRule.isBossTypeCanSelect(this.bossInfo.type);
                }
            }
            else
            {
                this._selectable = true;
            }
            return;
        }// end function

        protected function playBirthEffect(param1:String) : void
        {
            var _loc_2:EffectPlayer = null;
            if (Global3D.loadResource)
            {
                _loc_2 = EffectPlayerPool.instance.getEffectPlayer(param1, this, null, true, true, false);
                _loc_2.play(PlayMode.ANIMATION_STOP_MODE);
            }
            return;
        }// end function

        override public function updateClothes(param1:int) : void
        {
            return;
        }// end function

        override protected function updateOther(param1:SEntityInfo, param2:Boolean = true) : void
        {
            var _loc_3:Vector.<Array> = null;
            var _loc_4:Array = null;
            var _loc_5:int = 0;
            var _loc_6:TRobot = null;
            var _loc_7:TPlayerModel = null;
            var _loc_8:int = 0;
            var _loc_9:Array = null;
            var _loc_10:Array = null;
            var _loc_11:EffectPlayer = null;
            super.updateOther(param1);
            if (this.bossInfo == null || param2)
            {
                this.bossInfo = BossConfig.instance.getInfoByCode(param1.code);
                if (this.bossInfo)
                {
                    this.bossInfo.initTalk();
                    this._selectable = BossRule.isBossTypeCanSelect(this.bossInfo.type) && param1.life > 0;
                    this._isEnemyTrap = this.bossInfo.type == EBossType._EBossTypeTrap && !EntityRelationUtil.isFriendly(entityInfo.entityInfo);
                    if (!param1.name)
                    {
                        param1.name = this.bossInfo.name;
                    }
                    this.updateHoverArea(this.bossInfo.mouseArea);
                    if (this.bossInfo.aiBehaviorLifeAction)
                    {
                        this.isLifeBoss = true;
                        _loc_3 = GameStrUtil.alzToArray(this.bossInfo.aiBehaviorLifeAction);
                        this.lifeArray = _loc_3[0];
                        this.actionArray = _loc_3[1];
                        _loc_5 = 0;
                        while (_loc_5 < this.lifeArray.length)
                        {
                            
                            this.lifeArray[_loc_5] = int(this.lifeArray[_loc_5]);
                            _loc_5++;
                        }
                    }
                    else
                    {
                        this.isLifeBoss = false;
                    }
                    if (!this._isEnemyTrap)
                    {
                        _bodyPlayer.load(this.getResource(E3DResourceType._EMesh) + ".md5mesh", this.getResource(E3DResourceType._EBone) + ".skeleton", this.getResource(E3DResourceType._ETexture));
                        bodyPlayer.material.materialParams.isOpenHerizionKil = GameDefConfig.instance.isOpenHerizionKilMonster(this.bossInfo.code);
                    }
                    if (this.bossInfo.modelScale)
                    {
                        this.modelScale = this.bossInfo.modelScale * 1 / 100;
                        _defaultScale = this.bossInfo.modelScale * 1 / 100;
                    }
                    if (!this._hairPlayer)
                    {
                    }
                    if (!_loc_6)
                    {
                    }
                    if (_loc_7)
                    {
                    }
                    if (!this._weaponPlayer)
                    {
                    }
                    if (entityInfo.entityInfo.level < GameDefConfig.instance.getSystemOpenLevel(63))
                    {
                        switch(_loc_6.career)
                        {
                            case ECareer._ECareerWarrior:
                            {
                                break;
                            }
                            case ECareer._ECareerArcher:
                            {
                                break;
                            }
                            case ECareer._ECareerMage:
                            {
                                break;
                            }
                            case ECareer._ECareerPriest:
                            {
                                break;
                            }
                            default:
                            {
                                break;
                                break;
                            }
                        }
                    }
                    if (this.bossInfo.hangModel)
                    {
                        _loc_4 = this.bossInfo.hangModel.split("#");
                        if (_loc_4.length >= 4)
                        {
                            if (!this._hangPlayer)
                            {
                                this._hangPlayer = FrObjectPool.getObject(ActionPlayer, this);
                                this._hangPlayer.changeAction(ActionName.Stand);
                                this._hangPlayer.selectEnabled = true;
                                this._hangPlayer.timerContorler = this.timerContorler;
                                this._hangPlayer.play();
                            }
                            this._hangPlayer.load(_loc_4[0], _loc_4[1], _loc_4[2]);
                            this._hangPlayer.hangBoneName = _loc_4[3];
                            _bodyPlayer.hang(this._hangPlayer);
                        }
                    }
                    if (this.bossInfo.selfEffect)
                    {
                        _loc_3 = GameStrUtil.alzToArray(this.bossInfo.selfEffect);
                        _loc_9 = _loc_3[0];
                        _loc_10 = _loc_3[1];
                        _loc_5 = 0;
                        while (_loc_5 < _loc_9.length)
                        {
                            
                            if (this._effectPlayerArray.length > _loc_5)
                            {
                                _loc_11 = this._effectPlayerArray[_loc_5];
                                _bodyPlayer.unHang(_loc_11);
                                _loc_11.dispose();
                            }
                            _loc_11 = EffectPlayerPool.instance.getEffectPlayer(_loc_9[_loc_5], _bodyPlayer, null, true, true, false);
                            this._effectPlayerArray[_loc_5] = _loc_11;
                            if (_loc_10.length > _loc_5)
                            {
                                _loc_11.hangBoneName = _loc_10[_loc_5];
                            }
                            if (_loc_11.temple is TempleRole)
                            {
                                (_loc_11.temple as TempleRole).setRoleParams(_bodyPlayer, null, null);
                            }
                            else
                            {
                                _bodyPlayer.hang(_loc_11);
                            }
                            _loc_11.play(PlayMode.ANIMATION_LOOP_MODE);
                            _loc_5++;
                        }
                    }
                }
            }
            return;
        }// end function

        override public function updateHeadContainer() : void
        {
            var _loc_1:Boolean = false;
            var _loc_2:Boolean = false;
            var _loc_3:Boolean = false;
            if (this.bossInfo && (EBossType._EBossTypeTree == this.bossInfo.type || EBossType._EBossTypeSapling == this.bossInfo.type || GameMapUtil.curMapState.isWineMap && EBossType._EBossTypeCollect == this.bossInfo.type))
            {
                _headContainner.updateBloodVisible(false);
                _headContainner.updateNameVisible(true);
                _headContainner.updateGuildVisible(false);
                _headContainner.updateTitleVisible(false);
            }
            else
            {
                super.updateHeadContainer();
                if (this.isRobot)
                {
                    _loc_1 = entityInfo.isInLayer;
                    _loc_2 = this.selected;
                    _loc_3 = SystemSetting.instance.isHideOterPlayerName.bValue;
                    _headContainner.updateNameVisible(_loc_1 && !GameMapUtil.isInHideNameMap && !entityInfo.isInHidden && !entityInfo.isHide && (!_loc_3 || _loc_2 || this.entityInfo.isAttackRole));
                }
            }
            return;
        }// end function

        override protected function refreshActionNameCompl() : void
        {
            super.refreshActionNameCompl();
            if (this._hairPlayer)
            {
                this._hairPlayer.changeAction(_actionName);
                this._hairPlayer.play();
            }
            return;
        }// end function

        protected function getModelInfo(param1:int, param2:int, param3:int, param4:int) : TPlayerModel
        {
            return PlayerModelConfig.instance.getModelInfo(param1, param2, param4, param3);
        }// end function

        protected function updateHoverArea(param1:String) : void
        {
            var _loc_2:Array = null;
            if (param1)
            {
                _loc_2 = param1.split("#");
                hoverLeft = int(_loc_2[0]);
                hoverTop = int(_loc_2[1]);
                hoverWidth = int(_loc_2[2]);
                hoverHeight = int(_loc_2[3]);
            }
            else
            {
                hoverLeft = 50;
                hoverTop = 120;
                hoverWidth = 100;
                hoverHeight = 140;
            }
            return;
        }// end function

        override public function updateName(param1:String = null, param2:Boolean = true) : void
        {
            var _loc_4:String = null;
            if (!this.bossInfo || !BossRule.isBossTypeShowName(this.bossInfo.type) || this._isEnemyTrap)
            {
                return;
            }
            var _loc_3:String = "";
            if (entityInfo.entityInfo.guildName)
            {
                _loc_3 = entityInfo.entityInfo.guildName + NameUtil.Spacer;
            }
            else if (GameMapUtil.isForceNameMap())
            {
                _loc_3 = NameUtil.getHtmlForce(entityInfo);
            }
            else if (this.bossInfo.category == EBossCategory._EBossCategoryRobot && this.bossInfo.type == EBossType._EBossTypePlayerRobot)
            {
                _loc_3 = NameUtil.getRoleServerPrefix();
            }
            if (EntityRelationUtil.isCar(this.entityInfo.entityInfo.entityId))
            {
                _loc_4 = NameUtil.getCarName(this.entityInfo.entityInfo, param1);
            }
            if (!_loc_4)
            {
                if (this.bossInfo.type == EBossType._EBossTypeCollect)
                {
                    _loc_4 = _loc_3 + HTMLUtil.addColor(param1, "#FFFFFF");
                }
                else
                {
                    _loc_4 = _loc_3 + NameUtil.getNameHtmlByRelation(this.entityInfo.entityInfo, param1);
                }
            }
            entityInfo.updateIsEnemy();
            super.updateName(_loc_4, param2);
            return;
        }// end function

        override public function onMouseOver() : void
        {
            var _loc_1:int = 0;
            var _loc_2:int = 0;
            if (this._selectable)
            {
                if (this.bossInfo && this.bossInfo.type == EBossType._EBossTypeCollect)
                {
                    _loc_1 = 14596231;
                    _loc_2 = 0;
                    while (_loc_2 < _playerList.length)
                    {
                        
                        Global3D.scene.addSelectObject(_playerList[_loc_2], false, _loc_1);
                        _loc_2++;
                    }
                }
                else
                {
                    super.onMouseOver();
                }
            }
            return;
        }// end function

        override public function setAction(param1:String, param2:String, param3:Boolean = false) : void
        {
            if (this.isLifeBoss)
            {
                this.updateActionByLife();
            }
            else
            {
                super.setAction(param1, param2, param3);
            }
            return;
        }// end function

        override public function updateLevel(param1:int, param2:Boolean) : void
        {
            if (this.bossInfo)
            {
                if (this.bossInfo.category == EBossCategory._EBossCategoryBoss)
                {
                    _headContainner.updateLevel(param1, true);
                }
                else if (this.bossInfo.category == EBossCategory._EBossCategoryRobot && this.bossInfo.type == EBossType._EBossTypePlayerRobot)
                {
                    _headContainner.updateLevel(param1, false);
                }
            }
            return;
        }// end function

        override public function updateLife(param1:int, param2:int, param3:Boolean = false) : void
        {
            if (!this.bossInfo || !BossRule.isBossTypeShowLife(this.bossInfo.type))
            {
                return;
            }
            if (this.updateGuildTreeLife(param1, param2))
            {
                return;
            }
            if (param1 <= 0)
            {
                _headContainner.updateBloodVisible(false);
                this.monsterDeath();
                if (this.bossInfo.corpseTime == 0)
                {
                    _headContainner.updateNameVisible(false);
                }
                onMouseOut();
                if (ThingUtil.selectEntity == this)
                {
                    ThingUtil.selectEntity = null;
                }
            }
            else if (_headContainner && !_headContainner.bloodVisible)
            {
                this.updateBloodVisible();
            }
            this.updateSelectable();
            super.updateLife(param1, param2);
            if (this.isLifeBoss)
            {
                this.updateActionByLife();
            }
            return;
        }// end function

        private function updateGuildTreeLife(param1:int, param2:int, param3:Boolean = false) : Boolean
        {
            var _loc_4:String = null;
            if (EBossType._EBossTypeTree == this.bossInfo.type || EBossType._EBossTypeSapling == this.bossInfo.type)
            {
                _headContainner.updateGuildTreeVisible(true);
                _loc_4 = "";
                if (EBossType._EBossTypeTree == this.bossInfo.type)
                {
                    ThingUtil.guildCollectTreeUtil.updateJsonStaue(entityInfo.entityInfo);
                    _loc_4 = ThingUtil.guildCollectTreeUtil.isNormalShow(entityInfo.entityInfo);
                    if (_loc_4 == null)
                    {
                        _loc_4 = Language.getStringByParam(20669, HTMLUtil.addColor("" + param1, "#00ff00"));
                    }
                }
                _headContainner.updateGuildTreeInfo(_loc_4);
                return true;
            }
            else
            {
                _headContainner.updateGuildTreeVisible(false);
            }
            return false;
        }// end function

        public function updateGuildTreeCDTime(param1:String) : void
        {
            if (_headContainner)
            {
                _headContainner.updateGuildTreeInfo(param1);
            }
            return;
        }// end function

        override protected function getBloodType() : int
        {
            if (this.bossInfo && this.bossInfo.category == EBossCategory._EBossCategoryRobot)
            {
                if (EntityRelationUtil.isFriend(entityInfo.entityInfo))
                {
                    return EBloodType.Role;
                }
                return EBloodType.OtherPlayer;
            }
            else
            {
                if (this.bossInfo && this.bossInfo.category == EBossCategory._EBossCategoryBoss)
                {
                    return EBloodType.Boss;
                }
                return EBloodType.Monster;
            }
        }// end function

        override protected function updateFighting(param1:Boolean = true) : void
        {
            super.updateFighting(param1);
            if (entityInfo.fighting && this.bossInfo)
            {
                this.topTalk(this.bossInfo.talkFightId);
            }
            return;
        }// end function

        protected function updateActionByLife() : void
        {
            var _loc_4:String = null;
            if (this.actionArray.length == 0)
            {
                return;
            }
            var _loc_1:* = _entityInfo.entityInfo.life;
            var _loc_2:* = _entityInfo.entityInfo.maxLife;
            var _loc_3:* = Math.ceil(_loc_1 * 100 / _loc_2);
            var _loc_5:int = 1;
            while (_loc_5 < this.lifeArray.length)
            {
                
                if (_loc_3 >= this.lifeArray[_loc_5])
                {
                    _loc_4 = this.actionArray[(_loc_5 - 1)];
                    break;
                }
                _loc_5++;
            }
            if (_loc_3 == 0)
            {
                _loc_4 = this.actionArray[(this.actionArray.length - 1)];
            }
            this.refreshActionName(_loc_4);
            return;
        }// end function

        override protected function updateActionName() : void
        {
            if (!this.isLifeBoss)
            {
                super.updateActionName();
            }
            return;
        }// end function

        override protected function refreshActionName(param1:String) : void
        {
            if (this.isLifeBoss)
            {
                _bodyPlayer.changeAction(param1);
                _bodyPlayer.play();
                updateNamePosition();
            }
            else
            {
                super.refreshActionName(param1);
                if (ActionType.isDeathAction(_actionName))
                {
                    if (!_bodyPlayer.hasAction(_actionName))
                    {
                        this.onDeathComplete();
                    }
                    else
                    {
                        this._isJudgeDeath = true;
                        this._judgeDeathTime = setTimeout(this.judgeDeath, 3000);
                    }
                }
            }
            return;
        }// end function

        protected function judgeDeath() : void
        {
            if (this._isJudgeDeath)
            {
                this.onDeathComplete();
            }
            return;
        }// end function

        override protected function onDeathComplete() : void
        {
            this._isJudgeDeath = false;
            clearTimeout(this._judgeDeathTime);
            super.onDeathComplete();
            return;
        }// end function

        override public function death(param1:Boolean = false) : void
        {
            entityInfo.isAttackRole = false;
            this._isNoticeRemove = true;
            this.updateLife(_entityInfo.entityInfo.life, _entityInfo.entityInfo.maxLife);
            FrEventDispatcher.instance.proxyDispatchEvent(this, PlayerEvent.ENTITY_DEAD, [this]);
            isDead = true;
            clearStateModel();
            if (!ActionType.isDeathAction(_actionName))
            {
                this.monsterDeath();
            }
            else if (this.bossInfo.corpseTime != 0 || !_bodyPlayer.hasAction(ActionName.Death))
            {
                this.deathCompl();
            }
            return;
        }// end function

        protected function monsterDeath() : void
        {
            if (!ActionType.isDeathAction(this.actionName))
            {
                this.setAction(ActionType.Death, ActionName.Death);
                if (this.tboss.deathEffect)
                {
                    SkillEffectUtil.addPointEffect(new Point(this.x2d, this.y2d), this.tboss.deathEffect, false, this.direction);
                }
            }
            return;
        }// end function

        override protected function deathCompl() : void
        {
            super.deathCompl();
            if (!this._isNoticeRemove && this.bossInfo.corpseTime)
            {
                return;
            }
            var deathTime:* = this.tboss.deathEffect ? (1) : (2);
            _headContainner.updateNameVisible(false);
            this.removeHangEffect();
            this._deathTween = TweenLite.to(this.bodyPlayer, deathTime, {alpha:0.2, onComplete:function () : void
            {
                dispose();
                _deathTween = null;
                return;
            }// end function
            });
            return;
        }// end function

        public function judgeLifeTalk() : void
        {
            var _loc_1:int = 0;
            if (this.bossInfo && this.bossInfo.topTalk && entityInfo)
            {
                _loc_1 = entityInfo.entityInfo.life * 100 / entityInfo.entityInfo.maxLife;
                if (_loc_1 <= this.bossInfo.talkLifeMax && _loc_1 > this.bossInfo.talkLifeMin)
                {
                    this.topTalk(this.bossInfo.talkLifeId);
                }
            }
            return;
        }// end function

        public function judgeNormalTalk() : void
        {
            if (this.bossInfo)
            {
                this.topTalk(this.bossInfo.talkNormalId);
            }
            return;
        }// end function

        protected function topTalk(param1:int) : void
        {
            var _loc_2:TalkInfo = null;
            var _loc_3:String = null;
            if (param1 && (this._nextTalkTime == 0 || this._nextTalkTime < getTimer()))
            {
                this.clearFollowTalk();
                _loc_2 = TalkConfig.instance.getInfoById(param1);
                _loc_3 = _loc_2.randomTalk();
                if (_loc_3)
                {
                    LayerManager.entityTalkLayer.addTalk(this, _loc_3);
                    this._nextTalkTime = getTimer() + _loc_2.talkNextTime * 1000;
                    if (_loc_2.followTalk)
                    {
                        this.followTalk(_loc_2.followTalk);
                    }
                    if (_loc_2.followAction)
                    {
                        this.refreshActionName(_loc_2.followAction);
                    }
                }
            }
            return;
        }// end function

        protected function followTalk(param1:int) : void
        {
            this._followTalkTime = setTimeout(this.topTalk, 5000, param1);
            return;
        }// end function

        protected function clearFollowTalk() : void
        {
            if (this._followTalkTime)
            {
                clearTimeout(this._followTalkTime);
                this._followTalkTime = 0;
            }
            return;
        }// end function

        protected function removeHangEffect() : void
        {
            var _loc_1:int = 0;
            while (_loc_1 < this._effectPlayerArray.length)
            {
                
                _bodyPlayer.unHang(this._effectPlayerArray[_loc_1]);
                this._effectPlayerArray[_loc_1].dispose();
                _loc_1++;
            }
            this._effectPlayerArray.length = 0;
            return;
        }// end function

        protected function getResource(param1:int) : String
        {
            var _loc_2:Array = null;
            var _loc_3:int = 0;
            var _loc_4:Array = null;
            var _loc_5:Array = null;
            var _loc_6:int = 0;
            var _loc_7:Array = null;
            if (this.bossInfo.aiBehaviorLifeAction && this.bossInfo.aiBehaviorLifeAction.indexOf("*") != -1)
            {
                _loc_2 = this.bossInfo.aiBehaviorLifeAction.split("*");
                if (_loc_2[0] != param1)
                {
                    return this.getDefaultResource(param1);
                }
                _loc_3 = entityInfo.entityInfo.maxMana - entityInfo.entityInfo.mana;
                _loc_4 = String(_loc_2[1]).split("&");
                _loc_6 = 0;
                while (_loc_6 < _loc_4.length)
                {
                    
                    _loc_7 = String(_loc_4[_loc_6]).split("#");
                    if (_loc_4[(_loc_6 - 1)] == null)
                    {
                        if (_loc_3 >= 0 && _loc_3 <= _loc_7[0])
                        {
                            return _loc_7[1];
                        }
                    }
                    else
                    {
                        _loc_5 = String(_loc_4[(_loc_6 - 1)]).split("#");
                        if (_loc_3 > _loc_5[0] && _loc_3 <= _loc_7[0])
                        {
                            return _loc_7[1];
                        }
                    }
                    _loc_6++;
                }
            }
            return this.getDefaultResource(param1);
        }// end function

        private function getDefaultResource(param1:int) : String
        {
            if (param1 == E3DResourceType._ETexture)
            {
                return this.bossInfo.texture;
            }
            if (param1 == E3DResourceType._EBone)
            {
                return this.bossInfo.bone;
            }
            return this.bossInfo.mesh;
        }// end function

        override public function updateMana(param1:int, param2:int) : void
        {
            if (this.bossInfo && this.bossInfo.type == EBossType._EBossTypeShareCollect)
            {
                if (GameMapUtil.curMapState.isGuildWar)
                {
                    super.updateLife(param1, param2);
                }
                else
                {
                    this.updateCollectProgressBar(param2 - param1, param2);
                    this.updateCollectProBarXY();
                    if (_bodyPlayer.textTure != this.getResource(E3DResourceType._ETexture))
                    {
                        this.updateOther(entityInfo.entityInfo);
                    }
                }
            }
            return;
        }// end function

        protected function updateCollectProgressBar(param1:int, param2:int) : void
        {
            if (this._collectProBar == null)
            {
                this._collectProBar = UICompomentPool.getUICompoment(BaseProgressBar);
                this._collectProBar.setBg(ImagesConst.MountBarBg, true, 246, 13);
                this._collectProBar.setProgress(ImagesConst.MountBar, true, 4, 4, 238, 13);
                this._collectProBar.setLabel(BaseProgressBar.ProgressBarTextOnlyShowValue, 30);
                this._collectProBar.mouseEnabled = true;
                this._collectProBar.isOverShowValue = true;
                LayerManager.entityTalkLayer.addPopUp(this._collectProBar);
            }
            this._collectProBar.setValue(param1, param2, true);
            return;
        }// end function

        public function updateCollectProBarXY() : void
        {
            var _loc_1:int = 0;
            var _loc_2:int = 0;
            if (this._collectProBar)
            {
                _loc_1 = this.x2d - SceneRange.display.x - this._collectProBar.width / 2;
                _loc_2 = this.y2d - SceneRange.display.y - 150;
                this._collectProBar.x = _loc_1;
                this._collectProBar.y = _loc_2;
            }
            return;
        }// end function

        public function clearCollectProBar() : void
        {
            if (this._collectProBar)
            {
                LayerManager.entityTalkLayer.removePopup(this._collectProBar);
                this._collectProBar.dispose();
                this._collectProBar = null;
            }
            return;
        }// end function

        override public function dispose(param1:Boolean = true) : void
        {
            var _loc_2:Array = null;
            if (entityInfo == null)
            {
                _loc_2 = ObjectPool.getPool(MonsterPlayer);
                if (_loc_2.indexOf(this) >= 0)
                {
                    throw new Exception("MonsterPlayer重复释放");
                }
            }
            if (this._deathTween)
            {
                this._deathTween.kill();
                this._deathTween = null;
            }
            clearTimeout(this._judgeDeathTime);
            this._judgeDeathTime = 0;
            this._isJudgeDeath = false;
            this._isEnemyTrap = false;
            this._isNoticeRemove = false;
            this.isLifeBoss = false;
            this.isRobot = false;
            this._selectable = false;
            if (this._showTime)
            {
                clearTimeout(this._showTime);
            }
            this.lifeArray = new Array();
            this.actionArray = new Array();
            this.removeHangEffect();
            this.clearCollectProBar();
            if (this._hangPlayer)
            {
                _bodyPlayer.unHang(_bodyPlayer);
                this._hangPlayer.dispose();
                this._hangPlayer = null;
            }
            if (this._weaponPlayer)
            {
                _bodyPlayer.unHang(this._weaponPlayer);
                this._weaponPlayer.dispose();
                this._weaponPlayer = null;
            }
            if (this._hairPlayer)
            {
                _bodyPlayer.unHang(this._hairPlayer);
                this._hairPlayer.dispose();
                this._hairPlayer = null;
            }
            if (entityInfo)
            {
                ThingUtil.shareCollectEntityUtil.removeEntity(entityInfo.entityInfo.entityId);
                ThingUtil.guildCollectTreeUtil.removeEntity(entityInfo.entityInfo.entityId);
            }
            this._nextTalkTime = 0;
            this.clearFollowTalk();
            if (this._collectProBar)
            {
                this._collectProBar.dispose();
                this._collectProBar = null;
            }
            super.dispose(param1);
            return;
        }// end function

    }
}
